home *** CD-ROM | disk | FTP | other *** search
- /*============================================================
-
- N-Music/Sound Sample program
-
- ============================================================*/
-
- #include "N_Library.h"
-
- WindowPtr CreateWindow (Str255 name);
-
-
- #define WindowSizeX 320
- #define WindowSizeY 240
-
- short NewWindowX;
- short NewWindowY;
-
- short Data_Rsrc = 0;
-
-
- short Sounds[] = { 1000,1001,0 }; //'SND'resource id
- short Music1[] = { 1000,1001,-1 }; //music 1 block (1000,1001,1001,1001,,,,)
-
- void main(void)
- {
- WindowPtr window;
-
- ToolboxInit();
- ColorCheck();
- window = CreateWindow("\pN Game Library <Audio Sample>");
-
- Open_Resource_File(128,1,&Data_Rsrc);
- N_Pict_Draw(128,0,0,(GrafPtr)window,true);
- N_Sound_Load(&Sounds[0]); //open sound channels and read 'SND'
- Close_Resource_File(&Data_Rsrc);
- N_Music_Set(1,&Music1[0]); //set up music1 blocks
- N_Music_Play(1); //play music1
-
- do
- {
- }
- while (!Button());
-
- N_Music_Out(180); //Fade out
- do
- {
- }
- while (FO_Flag == true);
-
- N_Music_Kill();
- N_Sound_Close(); //close sounds channels
- ColorRevert();
-
- }
-
-
- WindowPtr CreateWindow (Str255 name)
- {
- WindowPtr window;
- short centerX,centerY;
- short windowWidth,windowHeight;
-
-
- window = GetNewWindow (128,nil,(WindowPtr)-1L );
- centerX = (qd.screenBits.bounds.right -qd.screenBits.bounds.left)/2;
- centerY = (qd.screenBits.bounds.bottom -qd.screenBits.bounds.top)/2;
- SetWTitle(window,name);
- MoveWindow(window,NewWindowX=centerX-(WindowSizeX/2),NewWindowY=centerY-(WindowSizeY/2),false);
- SizeWindow(window,WindowSizeX,WindowSizeY,TRUE);
-
- ShowWindow(window);
- SetPort((GrafPtr)window );
- return (WindowPtr)window;
- }
-
-
-